﻿namespace Core
{
    public class WaitMessageInst : Component, IInstruction, IAwake<string>,
        IStartUpdateFinish
    {
        private string eventName;

        public bool IsComplete { get; private set; }

        public void Awake(string eventName)
        {
            this.eventName = eventName;
        }

        public void Start()
        {
            IsComplete = false;
            Messenger.AddListener(eventName, OnEventHandler);
        }

        public void Update()
        {
        }

        public void Finish()
        {
            Messenger.RemoveListener(eventName, OnEventHandler);
        }

        private void OnEventHandler()
        {
            IsComplete = true;
        }
    }
}
